package com.sgcc.pda.frme.protocol.ws.sendbean;


import com.sgcc.pda.frme.protocol.ws.DataConvert;

/**
 * 电能表接线错误参数
 * guorongxin
 */
public class MeterJXCWDataParams {
    String meterAddress;//电表地址
    String fzlx;//负载类型
    String glys1;//功率因数1
    String glys2;//功率因数2

    public MeterJXCWDataParams(String meterAddress, String fzlx, String glys1, String glys2) {
        this.meterAddress = meterAddress;
        this.fzlx = fzlx;
        this.glys1 = glys1;
        this.glys2 = glys2;
    }

    public String getMeterAddress() {
        return meterAddress;
    }

    public void setMeterAddress(String meterAddress) {
        this.meterAddress = meterAddress;
    }

    public String getFzlx() {
        return fzlx;
    }

    public void setFzlx(String fzlx) {
        this.fzlx = fzlx;
    }

    public String getGlys1() {
        return glys1;
    }

    public void setGlys1(String glys1) {
        this.glys1 = glys1;
    }

    public String getGlys2() {
        return glys2;
    }

    public void setGlys2(String glys2) {
        this.glys2 = glys2;
    }

    /**
     * 将请求数据转化为byte数组
     *
     * @return 请求数据
     */
    public byte[] fromBytes() {
        return DataConvert.toBytes(toString());
    }


    /**
     * 将请求数据转化为字符串
     *
     * @return 请求数据
     */
    public String toString() {
        StringBuffer result = new StringBuffer();
        if (null == meterAddress || meterAddress.length() != 12) {
            return null;
        }
        result.append(DataConvert.strReverse(meterAddress, 0, meterAddress.length()));
        if (null == fzlx || fzlx.length() != 2) {
            return null;
        }
        result.append(fzlx);

        if (null == glys1 || glys1.length() != 2) {
            return null;
        }
        result.append(glys1);
        if (null == glys2 || glys2.length() != 2) {
            return null;
        }
        result.append(glys2);
        return result.toString();
    }
}
